import java.util.ArrayList;


public class D {

	private ArrayList<String> dico;
	public static D instance = null;
	
	/*Factory singleton*/
	
	public static D getInstance()
	{
		if(instance==null)
			instance = new D();
		return instance;
	}
	
	/*Constructeurs*/
	
	public D()
	{
		dico = new ArrayList<String>();
	}
	
	/* accesseurs */
	
	public ArrayList<String> getDico()
	{
		return this.dico;
	}
	
	public int size()
	{
		return this.dico.size();
	}

	/*fonction */
	
	public int code(String s)
	{
		if(dico.contains(s))
		{
			return dico.indexOf(s);
		}
		else
		{
			dico.add(s);
			return dico.indexOf(s);
		}
	}
	
	public V code(String[] s)
	{
		V result = new V();
		for(int i=0; i<s.length; i++)
		{
			result.getVecteur().add(code(s[i]));
		}
		return result;
	}
	
	public String decode(int i)
	{
		return dico.get(i);
	}
	
	
	/* fonction d'affichage */
	
	@Override
	public String toString() {
		String tmp = null;
		tmp = "_______________________\n";
		tmp += "Dictionnaire ::\n";
		for(int i = 0; i < this.dico.size();i++)
		{
			tmp += i + " " +this.dico.get(i) + "\n";
		}
		tmp += "\n_______________________\n";
		return tmp;
	}
	
	/* Test unitaire */
	
	public static void main(String Args[]){
		
		int i = D.getInstance().code("zero");
		i = D.getInstance().code("un");
		String[] chtxt  = new String[3];
		chtxt[0] = "deux";
		chtxt[1] = "trois";
		chtxt[2] = "quatre";
		
		@SuppressWarnings("unused")
		V v1 = D.getInstance().code(chtxt);
		
		
		System.out.println(i);
		System.out.println(D.getInstance().decode(i));
		
		System.out.println(D.getInstance().toString());
	}

	
	
}

